<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="/templates/layout.xhtml">
	<ui:define name="corpo">
		<p:growl id="mensagens" life="10000" />
		<div class="cadastro">
			<div id="descricao">
				<span id="descricao">Cadastro de Usuário</span>
			</div>
			<p:fieldset>
				<p class="info">
					<h:outputText value="#{msg.txt_info}" escape="false" />
				</p>
				<h:form id="cadastro" onsubmit="return validaCPF();">

					<h:inputHidden value="#{usuarioBean.usuario.codigo}" />
					<h:inputHidden value="#{usuarioBean.usuario.ativo}" />
					<h:inputHidden value="#{usuarioBean.veiculo.codigo}" />

					<p:fieldset>
						<div class="img_form_cadastro">
							<h:graphicImage library="imagens" name="cliente.jpg" width="60" />
						</div>
						<span>Meu Usuário</span>
						<h:panelGrid columns="2">
							<h:outputLabel value="Nome: * " for="nome" />
							<h:panelGroup>
								<p:inputText id="nome" label="nome"
									value="#{usuarioBean.usuario.nome}" size="30" maxLength="30"
									required="true" requiredMessage="Você não tem nome?">
									<f:validateLength minimum="10" maximum="30" />
								</p:inputText>
								<span id="erro"> <h:message for="nome" /> </span>
							</h:panelGroup>

							<h:outputLabel value="CPF: * " for="cpf" />
							<h:panelGroup>
								<p:inputMask id="cpf" label="cpf"
									value="#{usuarioBean.usuario.cpf}" size="11" maxLength="11"
									required="true" requiredMessage="Informe um cpf"
									mask="999.999.999-99" immediate="true">
									<f:converter converterId="com.sge.CPFConverter" />
									<f:validator validatorId="com.sge.CPFValidador" />
								</p:inputMask>
								<span id="erro"> <h:message for="cpf" /> </span>
							</h:panelGroup>

							<h:outputLabel value="Data Nascimento:" for="data" />
							<h:panelGroup>
								<p:calendar value="#{usuarioBean.usuario.dataNascimento}"
									requiredMessage="Informe data de nascimento" navigator="true"
									locale="pt" pattern="dd/MM/yyyy" maxdate="12/12/2012"
									mindate="12/12/1920">
									<f:convertDateTime pattern="dd/MM/yyyy" />
								</p:calendar>
								<span id="erro"> <h:message for="data" /> </span>
							</h:panelGroup>

							<h:outputLabel value="Senha: * " for="senha" />
							<h:panelGroup>
								<p:password id="senha" label="Senha"
									value="#{usuarioBean.usuario.senha}" size="15" maxlength="25"
									required="#{empty contextoBean.usuarioLogado}"
									redisplay="false" feedback="true"
									requiredMessage="Informe uma senha" weakLabel="Fraca"
									goodLabel="Boa" strongLabel="Forte"
									promptLabel="Por Favor insira uma senha" />
								<span id="erro"> <h:message for="senha" /> </span>
							</h:panelGroup>

							<h:outputLabel value="Confirmar Senha: * " for="confirmarsenha" />
							<h:panelGroup>
								<p:password id="confirmarsenha" label="Confirmar Senha"
									value="#{usuarioBean.confirmarSenha}" size="15" maxlength="20"
									required="#{empty contextoBean.usuarioLogado}"
									redisplay="false" requiredMessage="Confirme senha informada" />
								<span id="erro"> <h:message for="confirmarsenha" /> </span>
							</h:panelGroup>
						</h:panelGrid>

					</p:fieldset>


					<p:fieldset>
						<div class="img_form_cadastro">
							<h:graphicImage library="imagens" name="endereco.jpg" width="80" />
						</div>
						<span>Meu Endereço </span>


						<h:inputHidden value="#{usuarioBean.endereco.endereco}" />

						<p:panel id="panel" style="border:0;">
							<h:panelGrid columns="2">
								<h:outputLabel for="cep" value="Cep: *" />

								<h:panelGroup>
									<h:panelGrid columns="2">
										<p:inputMask id="cep" value="#{usuarioBean.cep}"
											required="true" requiredMessage=" * Cep inválido"
											mask="99999-999" size="10" />
										<h:panelGroup>
											<h:commandLink actionListener="#{usuarioBean.consultaCep}">
												<h:graphicImage library="imagens" name="lupa.png" width="25" />
												<f:ajax execute="panel" render="panel" />
											</h:commandLink>
											<span id="erro"> <h:message for="cep" /> </span>
										</h:panelGroup>
									</h:panelGrid>
								</h:panelGroup>

								<h:outputLabel for="logradouro" value="Logradouro : " />
								<p:inputText id="logradouro" size="30" required="true"
									value="#{usuarioBean.endereco.logradouro}" label="Logradouro"
									readonly="true" />

								<h:outputLabel for="bairro" value="Bairro : " />
								<p:inputText id="bairro" size="30" required="true"
									value="#{usuarioBean.endereco.bairro}" label="bairro"
									readonly="true" />

								<h:outputLabel for="cidade" value="Cidade : " />
								<p:inputText id="cidade" size="30" required="true"
									value="#{usuarioBean.endereco.cidade}" label="cidade"
									readonly="true" />

								<h:outputLabel for="uf" value="Estado : " />
								<p:inputText id="uf" size="10" required="true"
									value="#{usuarioBean.endereco.uf}" label="Estado"
									readonly="true" />

								<h:outputLabel for="numero" value="Número :" />
								<h:panelGroup>
									<p:inputText id="numero" size="10" required="true"
										requiredMessage=" * Digite um número "
										validatorMessage="Digite apenas números correspodentes de 0 a 9 ."
										value="#{usuarioBean.numero}" label="Numero">

										<f:validateRegex pattern="([1-9]){1,5}" />

									</p:inputText>
									<span id="erro"> <h:message for="numero" /> </span>
								</h:panelGroup>

								<h:outputLabel for="complemento" value="Complemento : " />
								<p:inputText id="complemento" size="20"
									value="#{usuarioBean.complemento}" label="Complemento" />
							</h:panelGrid>
						</p:panel>
					</p:fieldset>

					<p:fieldset>
						<div class="img_form_cadastro">
							<h:graphicImage library="imagens" name="contato.png" width="50" />
						</div>
						<span>Meu Contato</span>


						<h:panelGrid columns="2">
							<h:outputLabel value="e-Mail: * " for="email" />
							<h:panelGroup>
								<p:inputText id="email" label="e-Mail"
									value="#{usuarioBean.usuario.email}" size="30" maxLength="50"
									required="true" requiredMessage="Informe um endereço de email">
									<f:validateRegex
										pattern="[a-zA-Z0-9\-\_\.]+@[a-zA-Z0-9\-\_\.]+" />
								</p:inputText>
								<span id="erro"> <h:message for="email" /> </span>
							</h:panelGroup>

							<h:outputText value="Telefone: * " for="telefone" />
							<h:panelGroup>
								<p:inputMask id="telefone" label="telefone" size="12"
									value="#{usuarioBean.telefone.num_telefone}" required="true"
									mask="(99)99999-9999" requiredMessage="Informe um telefone" />
								<span id="erro"> <h:message for="telefone" /> </span>
							</h:panelGroup>

						</h:panelGrid>


					</p:fieldset>


					<p:fieldset>

						<div class="img_form_cadastro">
							<h:graphicImage library="imagens" name="veiculo.png" width="50" />
						</div>
						<span>Meu Veículo</span>

						<h:panelGrid columns="6">
							<h:outputLabel value="Placa: * " for="placa" styleClass="mr5" />
							<h:panelGroup>
								<p:inputMask id="placa" label="placa"
									value="#{usuarioBean.veiculo.placa}" size="8" mask="aaa-9999"
									styleClass="mr10" required="true" />
								<span id="erro"> <h:message for="veiculo" /> </span>
							</h:panelGroup>

							<h:outputLabel value=" Modelo: * " for="modelo" styleClass="mr5" />
							<h:panelGroup>
								<p:inputText id="modelo" label="modelo"
									value="#{usuarioBean.veiculo.modelo}" size="15" maxlength="30"
									styleClass="mr10" required="true" />
								<span id="erro"> <h:message for="modelo" /> </span>
							</h:panelGroup>

							<h:outputLabel value="Categoria:" for="categoria"
								styleClass="mr5" />
							<h:panelGroup>
								<p:inputText id="categoria" label="categoria"
									value="#{usuarioBean.veiculo.categoria}" size="15"
									maxlength="30" styleClass="mr10" />
							</h:panelGroup>
							<span id="erro"> <h:message for="categoria" /> </span>
						</h:panelGrid>
					</p:fieldset>

					<div align="left">
						<h:commandButton action="#{usuarioBean.alterar}" value="Salvar"
							styleClass="css3button" />
						<h:commandLink styleClass="css3button" action="javascript:history.back(1);" value="Voltar"/> 
					</div>
				</h:form>

			</p:fieldset>

		</div>

	</ui:define>
</ui:composition>
</html>
